
from functools import reduce
from typing import Counter
import re

def adjacentElementsProduct(inputArray : list[int] ):
    return max(list(map(lambda x : x[0] * x[1]  , list(zip(inputArray[0:-1],inputArray[1:])) ) ))

def allLongestStrings(inputArray : list[str]):
    return list(filter( lambda x : len(x) == max(map(lambda x :len(x) ,inputArray) ) ,inputArray ))

def checkPalindrome(inputString:str):
    return reduce(lambda x , y : x and ( inputString[y] == inputString[len(inputString) - 1 - y] )  ,[ i for i in range(0,len(inputString) // 2 ) ],True)

def commonCharacterCount(s1, s2):
    return sum( list((Counter(s1) & Counter(s2)).values()) )

def areSimilar(A, B):
    return len(A) == len(B) and ((Counter(A) | Counter(B)) == ( Counter(A) & Counter(B) )) and list(map( lambda x : x[0] == x[1] , [ (A[i],B[i]) for i in range(0,len(A)) ] ) ).count(False) <= 2

def palindromeRearranging(inputString : str):
    return  list(map(lambda x : x % 2 == 0 , list(Counter(inputString).values()))).count(False) <= 1

def arrayReplace(inputArray, elemToReplace, substitutionElem) :
    return list( map( lambda x : substitutionElem if x == elemToReplace else x, inputArray ) )

def evenDigitsOnly(n):
    return reduce( lambda x , y: x and ((y - ord('0')) >= 0) and ((y - ord('0')) <= 8) and ((y - ord('0')) % 2==0)  , [ ord( str(n)[i] ) for i in range(0,len(str(n))) ] ,True)

def alphabeticShift(inputString):
    return ''.join(list(map( lambda x : 'a' if x == ord('z') else chr(x + 1) ,[ ord(inputString[i]) for i in range(0,len(inputString)) ])))

def firstDigit(inputString):
    return int(re.compile(r'[0-9]{1}').findall(inputString)[0])